﻿using System.Security.Cryptography;
using System.Text;

namespace OA.Common
{
    public class SecurityHelper
    {
        /// <summary>
        ///  MD5 密码加密
        ///  密码加密后皆为小写
        ///  123456 的 MD5 码为: e10adc3949ba59abbe56e057f20f883e
        /// </summary>
        /// <param name="password">要加密的密码</param>
        /// <returns></returns>
        public static string MD5Encrypt(string password)
        {
            byte[] b = Encoding.UTF8.GetBytes(password);
            b = new MD5CryptoServiceProvider().ComputeHash(b);
            string ret = "";
            for (int i = 0; i < b.Length; i++)
            {
                ret += b[i].ToString("x").PadLeft(2, '0');
            }
            return ret.ToLower();
        }
    }
}
